const express = require('express');
const router = express.Router();
const {
  getNotifications,
  markAsRead,
  markAllAsRead,
  deleteNotification,
  getUnreadCount
} = require('../controllers/notificationController');
const { protect } = require('../middlewares/authMiddleware');

/**
 * @swagger
 * /notifications:
 *   get:
 *     summary: 获取用户的通知列表
 *     tags: [Notifications]
 *     security:
 *       - bearerAuth: []
 *     responses:
 *       200:
 *         description: 成功获取通知列表
 */
router.get('/', protect, getNotifications);

/**
 * @swagger
 * /notifications/unread:
 *   get:
 *     summary: 获取未读通知数量
 *     tags: [Notifications]
 *     security:
 *       - bearerAuth: []
 *     responses:
 *       200:
 *         description: 成功获取未读通知数量
 */
router.get('/unread', protect, getUnreadCount);

/**
 * @swagger
 * /notifications/{notificationId}/read:
 *   put:
 *     summary: 标记通知为已读
 *     tags: [Notifications]
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: notificationId
 *         required: true
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: 成功标记通知为已读
 */
router.put('/:notificationId/read', protect, markAsRead);

/**
 * @swagger
 * /notifications/read-all:
 *   put:
 *     summary: 标记所有通知为已读
 *     tags: [Notifications]
 *     security:
 *       - bearerAuth: []
 *     responses:
 *       200:
 *         description: 成功标记所有通知为已读
 */
router.put('/read-all', protect, markAllAsRead);

/**
 * @swagger
 * /notifications/{notificationId}:
 *   delete:
 *     summary: 删除通知
 *     tags: [Notifications]
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: notificationId
 *         required: true
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: 成功删除通知
 */
router.delete('/:notificationId', protect, deleteNotification);

module.exports = router;
